Skip to content

Subtractive workflow: faces seen from inside, drawing in rooms, and picking on edges (#325) - #361

Merged
LogicalError merged 2 commits into
mainfrom
feature-325-subtractive-workflow
Nov 19, 2026
Merged

LogicalError merged 2 commits into
mainfrom
feature-325-subtractive-workflow

Conversation

@LogicalError

Copy link
Copy Markdown
Member

What this changes and why

A model's Subtractive Workflow setting draws its brushes from inside: they are the rooms, carved out of solid space. This tests that workflow throughout and fixes what was wrong with it, and with the walls of rooms carved by subtractive brushes, which are drawn from inside the same way.

Faces drawn turned round (every face of a model with the subtractive workflow, a subtractive brush's walls in any model) are seen from behind their brush's plane:

  • Their texture read mirrored. Their u now runs the other way, after the surface's uv matrix, so by default they read as the face does from the front, and a mirror set in the uv matrix still mirrors them. Tangents follow. Being the same for every mapping, it keeps texture lock and the uv tools exact.
  • A hotspot tile is laid out from the side the surface is drawn on, and toggling texture lock carries its settings over from that side.
  • An omni-directional decal reaches such a face from the side it is drawn on, and lies along its texture as it is seen.
  • A shape drawn on such a face keeps the side it was drawn on; before, it was turned to face out of the brush, so made into a brush it reached into the solid instead of into the room.

Drawing brushes on surfaces:

  • With the subtractive workflow, a shape pulled out of a room's surface makes a pillar (subtractive) and one pushed into it a pit (additive), the other way round from a normal model. The placement tools and a shape made into a brush both take the operation from ChiselModelComponent.OperationOutOfSurface.

Picking:

  • MathExtensions.PointInTriangle counts a point on an edge as in the triangle. A ray hitting the edge between two triangles of a surface found neither, so the surface's plane wasn't turned to the viewer and a surface hit from behind wasn't left out.

The wiki's Subtractive Workflow page now describes the setting.

Fixes #325

How it was tested (scene, steps, Unity version)

New ChiselSubtractiveWorkflowTests, with the setting on and against the same room carved out of a solid:

  • every generator and rooms carved several ways are drawn turned round; faces and normals face into the room; turning the setting on and off rebuilds; the input hash changes with it;
  • a room is drawn exactly as the same room carved out of a solid (triangles, normals, uvs, tangents, colors): boxes, a cylinder, a sphere, stairs, smoothing by group and by angle, double sided, a non-square texture, a painted and a displaced floor, a hotspot material, a trim decal;
  • textures aren't mirrored from inside unless mirrored on purpose; tangents follow the texture; hotspot tiles on a room's wall aren't mirrored and toggling its texture lock changes nothing on screen;
  • decals on a room's floor are whole and not mirrored; an omni decal lies along the floor's texture;
  • collisions from inside (raycasts, a character controller);
  • lighting rendered from inside: a lamp lights a room as a carved one, a pillar shadows it, the lightmap uvs match, and a baked lamp lights the floor and light probes as in a carved room, again after the room is changed;
  • placing and extruding a shape out of or into a room's floor gives a pillar or a pit;
  • picking: a ray finds a room's floor from inside and not from behind, also on its diagonal; a room's surface picked from inside faces the viewer;
  • a texture moved or turned with the uv tools on a room's floor moves as it is seen.

A small carved level built by hand (Unity 6.6) looked right from inside: rooms joined, a pillar, stairs, lamps, unmirrored textures, a column and a pit drawn on the floors, an omni decal.

Full EditMode suite in Unity 6.6 (6000.6.0f1) and Unity 7 (7000.0.0a12), no failures.

  • Compiles without warnings, in the editor and in a player build
  • Tests added or updated, and the EditMode tests pass

…s the subtractive workflow (#325)

Placement:
- In a model with the subtractive workflow the brushes are the empty space,
  so a shape pulled out of a room's surface cuts (a pillar) and one pushed
  into it adds (a pit), the other way round from a normal model.

Faces drawn turned round (a subtractive brush's walls, every face of a
model with the subtractive workflow) are seen from behind their brush's
plane, where their texture read mirrored:
- Their u runs the other way, after the surface's uv matrix, so by default
  they read as the face does from the front; a mirror in the uv matrix
  still mirrors them. Tangents follow.
- Being the same for every mapping, texture lock and the uv tools keep
  matching what is drawn.
- A hotspot tile is laid out from the side the surface is drawn on, and
  toggling texture lock carries its settings over from that side.
- An omni-directional decal reaches such a face from the side it is drawn
  on, and lies along its texture as it is seen.

Tests:
- ChiselSubtractiveWorkflowTests: every generator and rooms carved several
  ways are drawn turned round, faces and normals facing into the room;
  turning the setting on and off rebuilds; textures on every generator and
  on carved rooms aren't mirrored, unless mirrored on purpose; tangents
  follow the texture; decals on a room's floor are whole and not mirrored,
  an omni decal along the floor's texture.
- Placement: the operation for a shape pulled out or pushed in, with and
  without the subtractive workflow, and on the grid.
- Hotspot tiles on a room's wall aren't mirrored, and toggling its texture
  lock changes nothing on screen; texture lock on faces seen from inside.
- The subtractive workflow setting changes the model's input hash.
…ace on its edges (#325)

Shapes drawn on a surface:
- A shape drawn on a room's wall or floor (a surface seen from behind its
  brush's plane) keeps the side it was drawn on, instead of being turned to
  face out of the brush. Made into a brush, it now reaches out of the
  surface into the room, not into the solid behind it.
- The operation of a brush pulled out of or pushed into a surface is the
  model's (ChiselModelComponent.OperationOutOfSurface): it adds pulled out
  and cuts pushed in, the other way round with the subtractive workflow.
  The placement tools and a shape made into a brush both use it.

Picking:
- A point on an edge of a triangle is in it (MathExtensions.PointInTriangle),
  so a ray hitting the edge between two triangles of a surface finds the
  surface's side: its plane faces the viewer, and with back faces left out,
  a surface hit from behind is left out.

Tests (ChiselSubtractiveWorkflowTests unless said otherwise):
- A room built in a model with the subtractive workflow is drawn as the same
  room carved out of a solid: boxes, a cylinder, a sphere, stairs, smoothed
  by group and by the model's angle, double sided, a non-square texture, a
  painted and a displaced floor, a hotspot material, a trim decal.
- Collisions from inside a room: raycasts and a character controller.
- Lighting: a lamp lights a room as a carved one, a pillar shadows it, the
  lightmap uvs match, and a baked lamp lights the floor and light probes as
  in a carved room, again after the room is changed.
- A shape on a room's floor made into a brush is a pillar or a pit.
- A ray finds a room's floor from inside, not from behind, also on its
  diagonal; PointInTriangle on an edge or a corner; a subtractive workflow
  room's surface picked from inside faces the viewer.
- A texture moved or turned by the uv tools on a room's floor moves as it is
  seen.
@LogicalError
LogicalError merged commit a4fc671 into main Nov 19, 2026
6 checks passed
@LogicalError
LogicalError deleted the feature-325-subtractive-workflow branch November 19, 2026 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant